package DatabaseManaging.Models;

import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class Product{
	private Long id;
	private String name;
	private ArrayList<String> abbs;
	private String release;
	private String release_year;
	
	public Product() {
		super();
	}
	public Product(Product another){
		this.id=another.getId();
		this.name=another.getName();
		this.abbs=new ArrayList<String>(another.getAbbs());
		this.release=another.release;
		this.release_year=another.release_year;
	}

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public ArrayList<String> getAbbs() {
		return abbs;
	}
	public void setId(long id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setAbbs(ArrayList<String> abbs) {
		this.abbs = abbs;
	}
	public String getRelease() {
		return release;
	}
	public void setRelease(String release) {
		this.release = release;
	}
	public String getRelease_year() {
		return release_year;
	}
	public void setRelease_year(String release_year) {
		this.release_year = release_year;
	}
	@Override
	public String toString() {
		String str=("Id:"+this.getId());
		str=str+" -Name: "+this.getName()+" -Version:"+this.getRelease()+" -Year:"+this.getRelease_year();
		str=str+" -Abbs:"+this.getAbbs();
		return str;
	}
//	public Product prepareProductToInsert(Product p){
//		Product pout=new Product();
//		if(!Product.containsYear(p.release_year)){
//			
//		}
//	}
	public static boolean containsYear(String value){
		boolean year;
		Pattern yearPattern = Pattern
				.compile("20[0-9][0-9]");
		Matcher yearMatcher = yearPattern.matcher(value);
		year = yearMatcher.find() ? true : false;
		return year;
	}
	
	public static String getYear(String value){
		String year="";
		Pattern yearPattern = Pattern
				.compile("20[0-9][0-9]");
		Matcher yearMatcher = yearPattern.matcher(value);
		year = yearMatcher.find() ? yearMatcher.group() : value;
		return year;
	}
	
	public static void main(String[] args) {
		Product p=new Product();
		p.setName("javier");
		ArrayList<String> abbs=new ArrayList<String>();
		abbs.add("roman");
		p.setAbbs(abbs);
		Product p2=new Product(p);
		p2.getAbbs().add("riquelme");
		System.out.println(p.getAbbs());
		System.out.println(p2.getAbbs());
		p.getRelease();
	}

}
